import request from "@/utils/request";
import { PostFormVO, PostPageQuery, PostVO } from "./types";
import { AxiosPromise } from "axios";

export function getPostList(
  query: PostPageQuery
): AxiosPromise<PageResult<PostVO[]>> {
  return request({
    url: "/api/system/post/list",
    method: "get",
    params: query,
  });
}

export function getPostById(id?: number): AxiosPromise<PostVO> {
  return request({
    url: "/api/system/post/detail/" + id,
    method: "get",
  });
}

export function deletePostById(ids: string): AxiosPromise<PostVO> {
  return request({
    url: "/api/system/post/del",
    method: "delete",
    data: {
      ids: ids,
    },
  });
}

export function addPost(post: PostFormVO) {
  return request({
    url: "/api/system/post/add",
    method: "post",
    data: post,
  });
}

export function updatePost(post: PostFormVO) {
  return request({
    url: "/api/system/post/update",
    method: "put",
    data: post,
  });
}
